*********
* Interrupted pgms to create spell dataset
* K.Paula, 19.07.18
* Stata version: 15
**********

*********
* Interrupted pgms to create spell dataset
* Update from S. Carey, 16 Feb 2021
* Stata version: 16
**********



* I. Adding rows of observation for interruped pgms
*-----------------------------------------------------


	* Afghanistan
		
		* ID 426 Forces of Ismail Khan / Herat militia: 2 spells, 2001-2004 and 2012-11-14 – 2013-01-01
		expand 2 if id == 426
		
		* ID 206  Uzbek-Junbesh-e-Milli: 3 spells 20/04/1989 until 1993, then again pro-gov August 1996 until 25 September 1996, then again 22 December 2001 – 2007, Pro-government again on 16 June 2009 - NA. 
		expand 4 if id == 206
		
		* ID 209 Ittehad Islami: 2 spells 29/06/1992 - Sept 1996 | Dec 2003- N.A.
		expand 2 if id == 209
		
		* ID 208 Jamaat Islami: 2 spells 1992-04-28 – 1996-09-27 | 2001-12-22 –
		expand 2 if id == 208
		
		
	* Bangladesh 
		* ID 178 Bangladesh Chhatra League:  2 spells 23 June 1996 - 12 July 2001 | 6 Jan 2009- N.A.
		expand 2 if id == 178
		
		* ID 177 Jatiyatabadi Chhatra Dal (JCD): 3 spells  1 Jan 1979 - 24/3/1982 | 20/03/1991 - 30/03/1996 |  10/10/2001 - 29/10/2006
		expand 3 if id == 177
		
		
	* Congo-K
		* ID 430 FDLR: 3 spells Jan 1998 - July 2002 | Sept 2007- Dec 2008 | July 2013 - NA
		expand 3 if id == 430
		
		
	* Georgia	
		* ID 165 Forest Brothers: 2 spells 1998-01-01 – 2004-01-25 | 2005-11-17- NA --> not relevant for country year aggrgation
		expand 2 if id == 165
	
	
	* Iraq		
		* ID 234 Awakening Groups / Sahwa: 2 spells 2008-11 – 2011-12 | 2014 - NA
		expand 2 if id == 234
			
		* ID 229 Popular Army/ Jerusalem Army: 2 spells 1970-01-01 to 1991-02-28 | and from 1992-07-02 until 2003-04-09 --> not relevant for country year aggregation!
		expand 2 if id == 229

		
	* Indonesia
		* ID 318 Halilintar: 2 spells 1975-01-01 -– 1982-12-31 |  1995-01-01 – 2003-02-25
		expand 2 if id == 318
		
		
	* Libya
		* ID 599 Tripoli Military Council: 2 spells 2012 – 2012-08-08 | 2014-03-01 – 2014-08-04
		expand 2 if id == 599
		
		
	* Malawi
		* ID 480 Youth Cadets: 2 spells 2011-04-20 – 2012-04-07 | 2014-05-31 – 2020-06-28  
		expand 2 if id == 480		
	
	
	* Nepal		
		* ID 462 Young Communist League: 2 spells 18/08/2008 – 25/05/2009 | 29/08/2011 – 14/03/2013
		expand 2 if id == 462
	
	
	* Pakistan 
		* ID 182 Jamaat-i-Islami: 2 spells  July 1977-June 1988 | Nov 1990 - May 1992
		expand 2 if id == 182
	
		* ID 183 Muttahida Quami Movement: 4 spells Nov 1987 - Oct 1989| Nov 1990-June 1992 | 1997-02-17 – 1998-10 | Oct 2002-Feb 2013 (First spell not relevant for country year aggregation)
		expand 4 if id == 183
	
	
	* Philippines
		* ID 570 Tagum Death Squads: 2 spells 1998-07-01 — 2001-12-01 | 2004-01-01 — 2013-12-01
		expand 2 if id == 570
		
		
	* Sudan	
		* ID 276 Fertit Militiamen: 2 spells 1987-01-19 - late 1990 | restart 1997 - 2007-11-17
		expand 2 if id == 276
	
	
	* Zimbabwe
		* ID 104 War Vets: 2 spells 2000-04-21 — 2016-06-01 |  2017-11-24 — NA --> not relevant for country year aggregation!
		expand 2 if id == 104
		
		* ID 101 Youth Service Brigade / Green Bombers: 3 spells 2000-02-12 – 2009-02-01 | 2010-01-01 – 2012-01-01 | 2017-01-01 – 2017-12-31
		expand 3 if id == 101

	* Others not coded since two spells within a year --> would result in wrong aggregation based on the year level!
		* SOMALIA ID 609 Raskamboni/ Raas Kaambooni: 2 spells 20/08/2012 – 31/01/2013, 01/09/2013- --> not relevant for country year aggregation! Would results in wrong counting since two spells within one year
		* HAITI ID 363 Ton Ton Macoutes Type 1: 2 spells 12 Feb 1986-02-12 until 1991-02-97 | 1991-09-30 - 1994-10-19 --> not relevant for country year aggregation! Would results in wrong counting since two spells within one year
		* LIBYA ID 595 Al-Zintan Military Council: 2 spells 2011-08-23 – 2014-07-01 | 2014-08-04 – NA
		
		
	
* II. Generate spell-id
*--------------------------------
	
	
	bysort id: gen spell = _n
	label var spell "spell of interrupted PGMs"

	
* III. Recode all spells
*---------------------------------
	* Rule: 
	* if only end or start year:  end date = 31.12 XXXX, start date = 01.01.XXXX
	* if only end or start month: end date = 31/30. XX.XXXX, start date = 01.XX.XXXX
	
	
	
	* Afghanistan
		* ID 426 Forces of Ismail Khan / Herat militia: 2 spells, 2001-2004 and 2012-11-14 – 2013-01-01
		replace date_terminated = td(31dec2004) if id==426 & spell==1
		replace date_formed = td(14nov2012) if id==426 & spell==2
		replace date_terminated = td(31dec2012) if id==426 & spell==2
	
		* ID 206  Uzbek-Junbesh-e-Milli: 4 spells 20/04/1989 until 1993, then again pro-gov August 1996 until 25 September 1996, then again 22 December 2001 – 2007, Pro-government again on 16 June 2009 - NA. 
		replace date_terminated = td(31dec1993) if id==206 & spell==1
		replace date_formed = td(01aug1996) if id ==206 & spell ==2
		replace date_terminated = td(25sep1996) if id == 206 & spell == 2
		replace date_formed = td(22dec2001) if id ==206 & spell ==3
		replace date_terminated = td(31dec2007) if id == 206 & spell == 3
		replace date_formed = td(16jun2009) if id ==206 & spell ==4
		replace date_terminated = . if id == 206 & spell == 4
		
		* ID 209 Ittehad Islami: 2 spells 29/06/1992 - Sept 1996 | Dec 2003- N.A. // checked for last acitiviy: 2004 
		replace date_terminated = td(30sep1996) if id==209 & spell==1
		replace date_formed = td(01dec2003) if id ==209 & spell ==2
		replace date_terminated = . if id == 209 & spell == 2
		
		* ID 208 Jamaat Islami: 1992-04-28 – 1996-09-27 | 2001-12-22 – N.A. // checked for last activity: 2012
		replace date_terminated = td(27sep1996) if id==208 & spell==1
		replace date_formed = td(22dec2001) if id ==208 & spell ==2
		replace date_terminated = . if id == 208 & spell == 2
		
		
	* Bangladesh 
		* ID 178 Bangladesh Chhatra League:  2 spells 23 June 1996 - 12 July 2001 | 6 Jan 2009- N.A. // checked for last activity = 2014
		replace date_terminated = td(12jul2001) if id==178 & spell==1
		replace date_formed = td(06jan2009) if id ==178 & spell ==2
		replace date_terminated = . if id == 178 & spell == 2
		
		* ID 177 Jatiyatabadi Chhatra Dal (JCD): 3 spells  1 Jan 1979 - 24/3/1982 | 20/03/1991 - 30/03/1996 |  10/10/2001 - 29/10/2006
		replace date_terminated = td(24mar1982) if id==177 & spell==1
		replace date_formed = td(20mar1991) if id ==177 & spell ==2
		replace date_terminated = td(30mar1996) if id == 177 & spell == 2
		replace date_formed = td(10oct2001) if id ==177 & spell ==3
		replace date_terminated = td(29oct2006) if id == 177 & spell == 3
		
		
	* Congo-K
		* ID 430 FDLR: 3 spells Jan 1998 - July 2002 | Sept 2007- Dec 2008 | July 2013 - NA // checked for last activity = 2014
		replace date_terminated = td(31jul2002) if id==430 & spell==1
		replace date_formed = td(01sep2007) if id ==430 & spell ==2
		replace date_terminated = td(31dec2008) if id == 430 & spell == 2
		replace date_formed = td(01jul2013) if id ==430 & spell ==3
		replace date_terminated = . if id == 430 & spell == 3
		
		
	* Georgia	
		* ID 165 Forest Brothers: 2 spells 1998-01-01 – 2004-01-25 | 2005-11-17- NA --> not relevant for country year aggrgation // checked for last activity 2007
		replace date_terminated = td(25jan2004) if id==165 & spell==1
		replace date_formed = td(17nov2005) if id ==165 & spell ==2
		replace date_terminated = . if id == 165 & spell == 2
		
		
	* Iraq	
		* ID 234 Awakening Groups / Sahwa: 2 spells 2008-11 – 2011-12 | 2014 - NA
		replace date_terminated = td(31dec2008) if id==234 & spell==1
		replace date_formed = td(01jan2014) if id==234 & spell==2
		replace date_terminated = . if id == 234 & spell==2
		
		* ID 229 Popular Army/ Jerusalem Army: 2 spells 1970-01-01 to 1991-02-28 | and from 1992-07-02 until 2003-04-09 --> not relevant for country year aggregation!
		replace date_terminated = td(28feb1991) if id==229 & spell==1
		replace date_formed = td(02jul1992) if id ==229 & spell ==2
		replace date_terminated = td(09apr2003) if id == 229 & spell == 2

		
	* Indonesia
		* ID 318 Halilintar: 2 spells 1975-01-01 -– 1982-12-31 |  1995-01-01 – 2003-02-25
		replace date_terminated = td(31dec1982) if id==318 & spell==1
		replace date_formed = td(01jan1995) if id==318 & spell==2
		replace date_terminated = td(25feb2003) if id==318 & spell==2

		
	* Libya
		* ID 599 Tripoli Military Council: 2 spells 2012 – 2012-08-08 | 2014-03-01 – 2014-08-04
		replace date_terminated = td(08aug2012) if id==599 & spell==1
		replace date_formed = td(01mar2014) if id==599 & spell==2
		replace date_terminated = td(04aug2014) if id==599 & spell==2

		
	* Malawi
		* ID 480 Youth Cadets (DPP): 2 spells 2011-04-20 - 2012-04-07 | 2014-05-31 – 2020-06-28
		replace date_terminated = td(07apr2012) if id==480 & spell==1
		replace date_formed = td(31may2014) if id==480 & spell==2
		replace date_terminated = . if id==480 & spell==2  /* USED FOR VERSION UP TO 2014  */
		*replace date_terminated = td(28jun2020) if id==480 & spell==2  /* RUN ONLY FOR VERSION UP TO 2020 ! */
		
		
	* Nepal		
		* ID 462 Young Communist League: 2 spells 18/08/2008 – 25/05/2009 | 29/08/2011 – 14/03/2013
		replace date_terminated = td(25may2009) if id==462 & spell==1
		replace date_formed = td(29aug2011) if id ==462 & spell ==2
		replace date_terminated = td(14mar2013) if id == 462 & spell == 2
		
	
	* Pakistan
		* ID 182 Jamaat-i-Islami: 2 spells  July 1977-June 1988 | Nov 1990 - May 1992
		replace date_terminated = td(01jun1988) if id==182 & spell==1
		replace date_formed = td(01nov1990) if id ==182 & spell ==2
		replace date_terminated = td(01may1992) if id == 182 & spell == 2
		
		* ID 183 Muttahida Quami Movement: 4 spells Nov 1987 - Oct 1989| Nov 1990-June 1992 | 1997-02-17 – 1998-10 | Oct 2002-Feb 2013 (First spell not relevant for country year aggregation)
		replace date_terminated = td(31oct1989) if id== 183 & spell==1
		replace date_formed = td(01nov1990) if id == 183 & spell ==2
		replace date_terminated = td(30jun1992) if id == 183 & spell == 2
		replace date_formed = td(17feb1997) if id == 183 & spell ==3
		replace date_terminated = td(01oct1998) if id == 183 & spell == 3	
		replace date_formed = td(01oct2002) if id == 183 & spell ==4
		replace date_terminated = td(27feb2013) if id == 183 & spell == 4
		
		
	* Philippines
		* ID 570 Tagum Death Squads: 2 spells 1998-07-01 — 2001-12-01 | 2004-01-01 — 2013-12-01
		replace date_terminated = td(01dec2001) if id==570 & spell==1
		replace date_formed = td(01jan2004) if id==570 & spell==2
		replace date_terminated = td(01dec2013) if id==570 & spell==2
		
		
	* Sudan	
		* ID 276 Fertit Militiamen: 2 spells 1986-01-01 - 1990-11-10 | restart 1997 - 2007-11-17
		replace date_terminated = td(10nov1990) if id==276 & spell==1
		replace date_formed = td(01jan1997) if id ==276 & spell ==2
		replace date_terminated =td(17nov2007) if id == 276 & spell == 2
	

	* Zimbabwe
		* ID 104 War Vets: 2 spells 2000-04-21 — 2016-06-01 |  2017-11-24 — NA --> not relevant for country year aggregation!
		replace date_terminated = td(01jun2016) if id==104 & spell==1
		replace date_formed = td(24nov2017) if id==104 & spell==2
		replace date_terminated = . if id==104 & spell==2
		
		* ID 101 Youth Service Brigade / Green Bombers: 3 spells 2000-02-12 – 2009-02-01 | 2010-01-01 – 2012-01-01 | 2017-01-01 – 2017-12-31
		replace date_terminated = td(01feb2001) if id==101 & spell==1
		replace date_formed = td(01jan2010) if id==101 & spell==2
		replace date_terminated = td(31dec2011) if id==101 & spell==2
		replace date_formed = td(01jan2017) if id==101 & spell==3
		replace date_terminated = td(31dec2017) if id==101 & spell==3
	
	
	
